﻿
var DataProvider = {};
DataProvider.Account = [[0, ""]];
DataProvider._user = null;
DataProvider.GetUser = function () {
    var load = false;
    if (DataProvider._user != null) return DataProvider._user;
    _h.ajax({
        async: false,
        type: "GET",
        url: _h.ResolveClientUrl("~/Data/GetCurrentUser"),
        data: null,
        success: function (rh) {
            load = true;
            if (rh.Error == -1) {
                DataProvider._user = null;
                return;
            }
            DataProvider._user = rh;
        },
        dataType: "jsonp"
    });
    while (!load) { }
    return DataProvider._user;
};

DataProvider.GetYearDatas = function () {
    if (DataProvider.YearDatas == undefined || DataProvider.YearDatas == null) {
        var year = 2010;
        var yearArr = new Array();
        for (var i = 0; i < 20; i++) {
            yearArr.push({ Name: year + i, Value: year + i });
        }
        DataProvider.YearDatas = yearArr;
    }
    return DataProvider.YearDatas;

};

DataProvider.GetMonthDatas = function () {
    if (DataProvider.MonthDatas == undefined || DataProvider.MonthDatas == null) {
        var month = 1;
        var monthArr = new Array();
        for (var i = 0; i < 12; i++) {
            monthArr.push({ Name: month + i, Value: month + i });
        }
        DataProvider.MonthDatas = monthArr;
    }
    return DataProvider.MonthDatas;
};

DataProvider.OprerationsInCreateBill = [
    { BillOperationId: 1, Name: "支出" },
    { BillOperationId: 2, Name: "收入" },
    { BillOperationId: 5, Name: "借款" },
    { BillOperationId: 6, Name: "还款" },
    { BillOperationId: 7, Name: "放债" },
    { BillOperationId: 8, Name: "收债" }
];
DataProvider.Oprerations = [
    { BillOperationId: 1, Name: "支出" },
    { BillOperationId: 2, Name: "收入" },
    { BillOperationId: 5, Name: "借款" },
    { BillOperationId: 6, Name: "还款" },
    { BillOperationId: 7, Name: "放债" },
    { BillOperationId: 8, Name: "收债" },
    { BillOperationId: 3, Name: "转出" },
    { BillOperationId: 4, Name: "转入" }
];

Theme = {};
Theme.List = { Gray: "Gray", Blue: "Blue" };
Theme.Current = Theme.List.Gray;

Theme.ReLoadShare = function () {
    _h.ajax.loadCss("domext_min_css", _h.ResolveClientUrl("~/Content/" + Theme.Current + "/DomExtGray/gray.css"));
    _h.ajax.loadCss("Site", _h.ResolveClientUrl("~/Content/" + Theme.Current + "/Site.css"));
};

Theme.ReLoadIndexCss = function () {
    _h.ajax.loadCss("Index", _h.ResolveClientUrl("~/Content/" + Theme.Current + "/Index.css"));
};

Theme.AnimateIn = _h.Animate.Tween.Back.easeIn;
Theme.AnimateOut = _h.Animate.Tween.Back.easeOut;
Theme.AnimateDuration = 25;

var InitMnav = function () {
    var mnav = _g("#mnav");
    var btns = _g("h:btn", mnav);
    _h.addEvent(btns[0], "click", function () {
        _h.Redirect(_h.ResolveClientUrl("~/index.htm"));
    });
    _h.addEvent(btns[2], "click", function () {
        _h.Redirect(_h.ResolveClientUrl("~/Pages/Report.htm"));
    });
    _h.addEvent(btns[6], "click", function () {
        _h.Redirect(_h.ResolveClientUrl("~/Pages/Setting.htm"));
    });
};